<?php  
//    include("conn.php");
$hostname_conn = "localhost";
$database_conn = "xdq";
$username_conn = "root";//没改的话一般时root
$password_conn = "123456";
$conn = mysqli_connect($hostname_conn, $username_conn, $password_conn,$database_conn)or trigger_error(mysqli_error(),E_USER_ERROR);
    $userid = $_POST['userid']; 
    $sname = $_POST['sname']; 
    $snum = $_POST['snum'];
    $slesson = $_POST['slesson']; 
    $sclass = $_POST['sclass'];

    //注册
    if (!empty($sname&&$snum)) {  //当名字和学号都不等于空时返回true，被执行
        $sql1 = "insert into student values ('$userid','$sname','$snum',0)";  //0表示是否修改过信息
        if(mysqli_query($conn, $sql1)){
        	echo json_encode("student_success");
        }else{
        	echo $sql1;
        }
     }elseif(!empty($slesson&&$sclass)){//课程和班级都不为空时,根据你的userid插入到班级那个表中
      $sql2 = "insert into lesson(openid,slesson,sclass,setTime) values ('$userid','$slesson','$sclass',Now())";  
       if(mysqli_query($conn, $sql2)){
           echo json_encode("lesson_success");  
         }else{
         	echo  $sql2;
         }
     }else{
     	echo "fail";
     }
?>  